package cc.rengu.igas.bsps.core.service.trans;

import cc.rengu.igas.bsps.common.dao.LoginAuthoritySettingMapper;
import cc.rengu.igas.bsps.common.dao.impl.LoginAuthoritySettingMapperImpl;
import cc.rengu.igas.bsps.common.enums.RespCodeEnum;
import cc.rengu.igas.bsps.core.service.base.ManageService;
import cc.rengu.igas.bsps.facade.request.LoginAuthoritySettingRequest;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.service.model.BizResponse;
import cc.rengu.oltp.utility.util.ConvertUtil;

/**
 * 登录权限设置
 * Created by yuhongwen
 */
public class LoginAuthoritySettingService extends ManageService {
    @Override
    protected Object bizBeforeCust() throws Exception {
        LoginAuthoritySettingRequest loginAuthoritySettingRequest = new LoginAuthoritySettingRequest();
        ConvertUtil.convertOutput(loginAuthoritySettingRequest);
        return loginAuthoritySettingRequest;
    }

    @Override
    protected BizResponse bizProcessCust(Object request) throws Exception {
        LoginAuthoritySettingRequest loginAuthoritySettingRequest = (LoginAuthoritySettingRequest) request;

        LoginAuthoritySettingMapper loginAuthoritySettingMapper = new LoginAuthoritySettingMapperImpl();

        String instId = loginAuthoritySettingRequest.getHeader().getInstId();
        String mchntNo = loginAuthoritySettingRequest.getMchntNo();
        String userId = loginAuthoritySettingRequest.getUserId();
        String wechatAuth = loginAuthoritySettingRequest.getWechatAuth();
        String mobileAuth = loginAuthoritySettingRequest.getMobileAuth();
        String webAuth = loginAuthoritySettingRequest.getWebAuth();
        String devRiskInfo = loginAuthoritySettingRequest.getDevRiskInfo();
        String loginAuthFlag = wechatAuth + mobileAuth + webAuth;
        loginAuthoritySettingMapper.updateloginAuthFlagByPrimaryKey(instId, userId, loginAuthFlag);

        /* 按照接口转换基础产品信息并响应给请求方 */
        BizResponse bizResponse = new BizResponse();
        bizResponse.setRspSysId(AppParamConstant.SYS_ID);
        bizResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        bizResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());
        return bizResponse;
    }

    @Override
    protected void bizAfterCust(Object response) throws Exception {
        BizResponse bizResponse = (BizResponse) response;
    }

}

